<?php
namespace app\index\controller;
use app\index\model\Users as M;
/**
 * Created by Submint Text.
 * User: hetaoren<452649510@qq.com>
 * Date: 2017/03/10
 * Explain: 会员控制器
 */
class Mine extends Base{
    
    public function index(){
        $classifyList = model('classify')->field('classifyId,classifyName')->where(['dataFlag'=>1])->order('classifySort asc, classifyId asc')->select();
        $this->assign("classifyList",$classifyList);
        $diseaseList = model('disease')->field('diseaseId,diseaseName')->where(['dataFlag'=>1])->order('diseaseSort asc, diseaseId asc')->select();
        $this->assign("diseaseList",$diseaseList);
        $this->assign("staffRoleId",session("HTR_STAFF.staffRoleId"));
        $this->assign("staffId",session("HTR_STAFF.staffId"));
        return $this->fetch("list");
    }
    /**
     * 获取分页
     */
    public function pageQuery(){
        $m = new M();
        return $m->pageQuery();
    }
    /**
     * 跳去编辑页面
     */
    public function toEdit(){
        $classifyList = model('classify')->field('classifyId,classifyName')->where(['dataFlag'=>1])->order('classifySort asc, classifyId asc')->select();
        $this->assign("classifyList",$classifyList);
        $interestList = model('interest')->field('interestId,interestName')->where(['dataFlag'=>1])->order('interestSort asc, interestId asc')->select();
        $this->assign("interestList",$interestList);
        $m = new M();
        $data = $this->get();
        $diseaseList = model('disease')->field('diseaseId,diseaseName')->where(['dataFlag'=>1])->order('diseaseSort asc, diseaseId asc')->select();
        $this->assign("diseaseList",$diseaseList);
        $this->assign("areaList",model('areas')->listQuery(0));
        $this->assign("staffList",model('Staffs')->where('staffId',session("HTR_STAFF.staffId"))->column('staffName','staffId'));
        $assign = ['data'=>$data];
        return $this->fetch("edit",$assign);
    }
    /*
    * 获取数据
    */
    public function get(){
        $m = new M();
        return $m->getById((int)Input("id"));
    }
    /**
     * 新增
     */
    public function add(){
        $m = new M();
        return $m->add();
    }
    /**
    * 修改
    */
    public function edit(){
        $m = new M();
        return $m->edit();
    }
    /**
     * 删除
     */
    public function del(){
        return model('users')->del();
    }
}
